package main

import (
	"fmt"
	"time"
)

type Employee struct {
	ID        int
	Name      string
	Address   string
	DoB       time.Time
	Position  string
	salary    int
	ManagerID int
}
type tree struct {
	left, right *tree
	value       int
}

var dilbert Employee

func EmployeeByID(id int) *Employee {
	return &dilbert
}
func sort(values []int) {
	var root *tree
	for _, value := range values {
		root = add(root, value)
	}
	appendValues(values[:0], root)
}
func add(t *tree, value int) *tree {
	if t == nil {
		t = new(tree)
		t.value = value
		return t
	}
	if value < t.value {
		t.left = add(t.left, value)
	} else {
		t.right = add(t.right, value)
	}
	return t
}
func appendValues(values []int, t *tree) []int {
	if t != nil {
		values = appendValues(values, t.left)
		values = append(values, t.value)
		values = appendValues(values, t.right)
	}
	return values
}
func main() {
	dilbert.salary = 5000
	dilbert.Position = "Love "
	position := &dilbert.Position
	*position += "Senior"
	fmt.Println(*position)
	fmt.Println("----------指针 forwart struct--------")
	var employeeOfTheMonth *Employee = &dilbert
	employeeOfTheMonth.Position += " (proactive team player)"
	fmt.Println(employeeOfTheMonth)
	fmt.Println("struct of tree")

	root := add(nil, 5)
	add(root, 3)
	add(root, 4)
	add(root, 8)
	add(root, 2)
	add(root, 1)
	var values []int
	res := appendValues(values, root)
	fmt.Println(res)
	fmt.Println("--------struct comparable--------")
	hits := make(map[address]int)
	hits[address{"golang.org", 443}]++
	fmt.Println(hits)
	p := Point{1, 2}
	q := Point{2, 1}
	z := Point{2, 1}
	fmt.Println(p == q)
	fmt.Println(z == q)
	fmt.Println("---------struct 聚合---------")

}

type Circle struct {
	Center Point
	Radius int
}
type wheel struct {
	Circle Circle
	Spokes int
}
type address struct {
	hostname string
	port     int
}
type Point struct {
	X, Y int
}
